<?php

// When there is images/module_icon_custom.png
if (file_exists(XOOPS_ROOT_PATH . '/modules/' . $mydirname .'/images/module_icon_custom.png')) {
	$use_custom_icon = TRUE;
	$icon_fullpath = XOOPS_ROOT_PATH . '/modules/' . $mydirname .'/images/module_icon_custom.png';
} else {	//Write dirname in blank icon
	$use_custom_icon = FALSE;
	$icon_fullpath = dirname(__FILE__) . '/images/module_icon.png';
}

include dirname(__FILE__) . '/include/version.php';

//------------------------------------------
header("Content-type: image/png");

if (! $use_custom_icon && 
	function_exists('imagecreatefrompng') && function_exists('imagecolorallocate') && 
	function_exists('imagestring') && function_exists('imagepng')) 
{

	$im = imagecreatefrompng($icon_fullpath);
	$color = imagecolorallocate($im, 140, 30, 30);// RBG
	imagestring($im, 3, 31, 1, $mydirname, $color);// 127 * 24 px

	if (isset($_SERVER["HTTP_REFERER"])) {
		imagestring($im, 1, 31, 14, _MILEAGE_VERSION, $color);// ver
	}
	imagepng($im);
	imagedestroy($im);

} else {
	readfile($icon_fullpath);
}
